<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">广告位管理</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="loanSpaceListDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{loanProductSpaceListBean.isNormal()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{loanProductSpaceListBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanProductSpaceListBean.isNormal()}"/>
                        <p:commandButton icon="fa fa-plus" value="新增"
                                         action="#{loanProductSpaceListBean.onAdd}"
                                         rendered="#{loanProductSpaceListBean.isNormal()}">
                            <f:setPropertyActionListener value="/views/product/space/list.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="4" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:left;">

                                <p:outputLabel for="name" value="广告位名称"/>
                                <p:inputText id="name" value="#{loanProductSpaceListBean.$.name}"/>

                                <p:outputLabel for="type" value="广告位类型"/>
                                <p:selectOneMenu id="type" value="#{loanProductSpaceListBean.$.type}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="列表" itemValue="0"/>
                                    <f:selectItem itemLabel="推荐" itemValue="1"/>
                                    <f:selectItem itemLabel="专题" itemValue="2"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="parentPrdid" value="所属大产品"/>
                                <p:selectOneMenu id="parentPrdid"
                                                 value="#{loanProductSpaceListBean.$.parentPrdid}" filter="true"
                                                 filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems value="#{loanProductSpaceListBean.dictionaries[DictionaryCode.LARGE_COMMON_PRODUCT]}"
                                                   var="dic"
                                                   itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="loanSpaceListDataTable"
                                         style="width: 100%"
                                         var="space"
                                         value="#{loanProductSpaceListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         reflow="true"
                                         selection="#{loanProductSpaceListBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" style="width: 70px;text-align:center;"
                                          rendered="#{loanProductSpaceListBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-eye"
                                                   action="#{loanProductSpaceListBean.onEdit(space.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/product/space/list.xhtml"
                                                target="#{currentUserBean.back}"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple"
                                          rendered="#{loanProductSpaceListBean.isBatch()}"/>
                                <p:column headerText="所属大产品" style="text-align:center">
                                    <h:outputText value="#{space.large_products}"/>
                                </p:column>
                                <p:column headerText="广告位ID" style="text-align:center">
                                    <h:outputText value="#{space.spaceId}"/>
                                </p:column>
                                <p:column headerText="广告位名称">
                                    <h:outputText value="#{space.name}"/>
                                </p:column>
                                <p:column headerText="广告位类型" style="text-align:center">
                                    <h:outputText rendered="#{space.type==0}" value="列表"/>
                                    <h:outputText rendered="#{space.type==1}" value="推荐"/>
                                    <h:outputText rendered="#{space.type==2}" value="专题"/>
                                </p:column>
                                <p:column headerText="展示个数" style="text-align:center;">
                                    <h:outputText value="#{space.showCount}"/>
                                </p:column>
                                <p:column headerText="更新人" style="text-align:center;">
                                    <h:outputText value="#{space.updator}"/>
                                </p:column>
                                <p:column headerText="更新时间" style="width: 130px">
                                    <h:outputText value="#{space.updateTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
